package com.lemonsama.lesson3;

import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class KeyFrame extends Frame {
    public KeyFrame() {
        setBounds(1, 2, 300, 400);
        setVisible(true);

        this.addKeyListener(new KeyAdapter() {
            //键盘按下
            @Override
            public void keyPressed(KeyEvent e) {
                //获取键盘码，可以计算出按下的键
                int keyCode = e.getKeyCode();
                if (keyCode == e.VK_UP) {
                    System.out.println("你按下了上键");
                }
            }
        });
    }
}
